package com.yf.modules.system.model.dto;

import com.yf.domain.security.Role;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @author chentianwei
 * @date 2024-01-25 16:22
 * @description Role 小Dto
 */

@Getter
@Setter
public class RoleSmallDto implements Serializable {

    private Long id;
    private String name;
    private Integer level;
    private String dataScope;

    public static List<RoleSmallDto> convertToRoleSmallDto(Set<Role> roles) {
        List<RoleSmallDto> dtos = new ArrayList<>();

        for (Role role : roles) {
            RoleSmallDto dto = new RoleSmallDto();
            dto.setId(role.getId());
            dto.setName(role.getName());
            dto.setLevel(null);
            dto.setDataScope(null);
            dtos.add(dto);
        }


        return dtos;
    }
}
